import java.net.*;
import java.io.*;

public class server {
    public static void main(String[] args) throws IOException {
        try {
            ServerSocket ss = new ServerSocket(5000);
            Socket s = ss.accept();

            System.out.println("Connected to client");

            DataInputStream in = new DataInputStream(s.getInputStream());
            DataOutputStream out = new DataOutputStream(s.getOutputStream());

            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);

            String s1 = "", s2 = "";

            while (!s1.equals("bye")) {
                s1 = in.readUTF();
                System.out.print("From Client : ");
                System.out.println(s1);
                s2 = br.readLine();
                out.writeUTF(s2);
                out.flush();
            }
            s.close();
        } catch (Exception e) {
            System.out.print("Error");
        }
    }
}